#include<stdio.h>
#include<string.h>
char s[85];

int main(){
    int t;
    scanf("%d", &t);
    while(t--){
        scanf("%s", s);
        int n = strlen(s);
        int o = 0, result = 0;
        for(int i = 0; i < n; ++i){
            if(s[i] == 'O'){
                ++o;
                result += o;
            }else if(s[i] == 'X'){
                o = 0;
            }
        }
        printf("%d\n", result);
    }
}
